VERSION="\"getSim 0.1.0.0
VERSION64_SIGN=64bit\""
VERSION32_SIGN=\""

ifeq ($(MAC),64)
		VERSION+=$(VERSION64_SIGN)
		LIBPATH=$(WORKROOT)/lib2-64
else
		VERSION+=$(VERSION32_SIGN)
		LIBPATH=$(WORKROOT)/lib2
endif

mysql_header=$(shell mysql_config --cflags)
mysql_lib=$(shell mysql_config --libs)
#mysql_lib=-L/usr/lib/mysql  -lmysqlclient

CC=g++ -O2 -g

CFLAGS=-c -Wall -D__VERSION_ID__=$(VERSION)  ${mysql_header}  -I/usr/include
CXXFLAGS=-D__VERSION_ID__=$(VERSION)  ${mysql_lib} -lmongoclient -lboost_thread-mt -lboost_filesystem-mt -lboost_program_options-mt 
MAKE_TIME=`date "+%Y-%m-%d %H:%M:%S"`

EXE= getSim_latent \
	getSim_tfidf \
	updateNeighbor \
	getAvgSim
vpath %.h ../util
vpath %.o ../util
SOURCES= ../util/util.cpp ../util/ConfigFile.cpp DBBase.cpp RelatedQuestions.cpp \
		../util/filesystem.cpp loadData.cpp calSim.cpp SimTable.cpp \
	    Cluster.cpp SampleQuestion.cpp
OBJECTS=$(SOURCES:.cpp=.o)
#OBJECTS=$(notdir OBJECTS)

all:  $(OBJECTS) $(EXE)
.PHONY: all
getSim_latent: getSim_latent.o ${OBJECTS}
	$(CC)  getSim_latent.o ${OBJECTS} -o getSim_latent $(CXXFLAGS)  
getSim_tfidf: getSim_tfidf.o ${SOURCES}
	$(CC) getSim_tfidf.o ${OBJECTS} -o getSim_tfidf $(CXXFLAGS)  
updateNeighbor: updateNeigh.o ${SOURCES}
	$(CC) updateNeigh.o ${OBJECTS} -o updateNeighbor $(CXXFLAGS) 
getAvgSim: getAvgSim.o ${SOURCES}
	$(CC) getAvgSim.o ${OBJECTS} -o getAvgSim $(CXXFLAGS) 

getSim_latent.o: getSim_latent.cpp
	$(CC) $(CFLAGS) getSim_latent.cpp
getSim_tfidf.o: getSim_tfidf.cpp
	$(CC) $(CFLAGS) getSim_tfidf.cpp
updateNeigh.o: updateNeigh.cpp
	$(CC) $(CFLAGS) updateNeigh.cpp
getAvgSim.o: getAvgSim.cpp
	$(CC) $(CFLAGS) getAvgSim.cpp
$(OBJECTS): %.o : %.cpp
	$(CC) $(CFLAGS) $<  -o $@ 
.PHONY: clean #说明clean是个伪目标 
clean:
	rm -f ${OBJECTS} $(EXE) *.o
	rm -rf output
